package fun.werfamily.wf.base.dto;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: Mr.WenMing Zhang
 * @Date: 2023-04-24 21:42
 * @Description:
 */
public class LoginUserContext {
    private static final ThreadLocal<BaseUserInfoDTO> threadLocal = new ThreadLocal<>();

    public static String getUserCode(){
        BaseUserInfoDTO baseUserInfoDTO = threadLocal.get();
        if (null != baseUserInfoDTO) {
            return baseUserInfoDTO.getUserCode();
        }
        return null;
    }

    public static String getUserName(){
        BaseUserInfoDTO baseUserInfoDTO = threadLocal.get();
        if (null != baseUserInfoDTO) {
            return baseUserInfoDTO.getUserName();
        }
        return null;
    }

    public static BaseUserInfoDTO getBaseUser(){
        return threadLocal.get();
    }

    public static void remove(){
        threadLocal.remove();
    }

    public static void put(BaseUserInfoDTO baseUserInfoDTO){
        threadLocal.set(baseUserInfoDTO);
    }
}
